﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace WindowsFormsApplication1.wtyczki
{
    class Kwant
    {
        public static Bitmap KwantThis(Bitmap bm)
        {
            int nValue;
            Bitmap bmTmp = new Bitmap(bm);
            using (ScrollBar form2 = new ScrollBar("Quantumsation", 255))
            {
                form2.ShowDialog();
                nValue = form2.TheValue;
            }
            for (int y = 1; y < bm.Height; y++)
            {
                for (int x = 1; x < bm.Width; x++)
                {
                    int R=(int)(bm.GetPixel(x,y).R/nValue)*nValue;
                    int G=(int)(bm.GetPixel(x,y).G/nValue)*nValue;
                    int B=(int)(bm.GetPixel(x,y).B/nValue)*nValue;
                    bmTmp.SetPixel(x, y, Color.FromArgb(R, G, B));
                    
                }
            }


            return bmTmp;
        }
        public static Bitmap KwantThis(Bitmap bm, int Value)
        {
            int nValue=Value;
            Bitmap bmTmp = new Bitmap(bm);
            for (int y = 1; y < bm.Height; y++)
            {
                for (int x = 1; x < bm.Width; x++)
                {
                    int R = (int)(bm.GetPixel(x, y).R / nValue) * nValue;
                    int G = (int)(bm.GetPixel(x, y).G / nValue) * nValue;
                    int B = (int)(bm.GetPixel(x, y).B / nValue) * nValue;
                    bmTmp.SetPixel(x, y, Color.FromArgb(R, G, B));

                }
            }


            return bmTmp;
        }

    }
}
